package com.itheima.proxy01;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyDemo {
    public static void main(String[] args) {
        Study np = (Study) Proxy.newProxyInstance(Student.class.getClassLoader(), Student.class.getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if ("study".equals(method.getName())) {
                    System.out.println("学的飞起~~~");
                    return null;
                } else {
                    Student student = Student.class.newInstance();
                    method.invoke(student, args);
                    return null;
                }

            }
        });
        np.study();
        np.sleep();


    }



}
